<?php
$AbteilungID = 0;
if (!empty ($_GET["AbteilungID"])) {
	$AbteilungID = $_GET["AbteilungID"];
}
$sql = "SELECT * FROM firmaview WHERE AbteilungID=$AbteilungID";
$_rd = mysql_query($sql, $_db_link);
$kontakt = "<br><br><h3>" . LangTextOut("Kontakt") . ":</h3><br>";
$abteilung = "";
if ($_rd) {
	$Name = "";
	while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
		if ($str == "") {
			foreach ($daten as $name => $value) {
				if ($value != NULL && $name != "FirmaID" && $name != "UserID" && $name != "Sortiren" && $name != "Tables"
                       && $name != "Status" && $name != "LogoID" && $name != "KategorieID" && $name != "ID" && $name != "GalerieID") {
					if ($name == "AbteilungID") {
						$abteilung = " ";
					} else {

						if ($abteilung == "") {
							if ($name == "Name") {
								$Name = "<h3>$value</h3><br>";
							} else {
								if ($name == "Website") {
									$value = "<a href='$value'>$value</a>";
								}
								if ($name == "LinkMap") {
									$value = "<a href='javascript:showmap()' class='BootenLink'>" . LangTextOut("KarteAnzeigen") . "</a>";
								}
								$kontakt = $kontakt . "<b>" . LangTextOut($name) . " : </b>$value<br><br>";
							}
						} else {
							if ($Name != "") {
								$abteilung = $abteilung . $Name;
								$Name = "";
							}
							if ($name == "VideoLink") {
								if (stripos($value, 'watch?v=')) {
									$value = str_replace('watch?v=', 'v/', $value);
									//if ($i = strpos($value, '&'))
									//	$value = substr($value, $i, strlen($value) - $i);
									//echo $value;
								}
								$value = "<object width='425' height='350'>" .
								"<param name='movie' value='$value'></param>" .
								"<embed src='$value' type='application/x-shockwave-flash' width='425' height='350''></embed>" .
								"</object>";
							}
							if ($name == "Kategorie") {
								$value = str_replace("*", "<img src='Admin/phpimages/star.gif'>", $value);
							}
							if ($name == "kulturshowsID" || $name == "musseumID" || $name == "resturantID" || $name == "ausflugID") {

								$abteilung = $abteilung . "<hr><h3>" . LangTextOut($name) . "</h3><br>";

							} else {
								$abteilung = $abteilung . "<h4>" . LangTextOut($name) . " :</h4> $value<br><br>";
							}
						}
					}
				}
			}
			$logo = geFile($daten["LogoID"], 'smallPicView');
			$datamap = $daten["LinkMap"];
			$Gallery = $daten["GalerieID"];
		}
	}
}
$sql = "select * FROM zimmerview where AbteilungID=$AbteilungID";
$_rd = mysql_query($sql, $_db_link);
if ($_rd) {
	$sw = "row1";
	while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
		if (!$zimmer) {
			$zimmer = "<hr><table class='ZimmerList'>
						<tr class='$sw'>
						<td><b>" . LangTextOut("ZimmerType") . "<b/></td>
						<td><b>" . LangTextOut("NumerOfZimmer") . "<b/></td>
						<td><b>" . LangTextOut("Preis") . "<b/></td>" .
						"<td><b>" . LangTextOut("Buchung") . "<b/></td>
						</tr>
						";
		}
		if ($sw == "row1") {
			$sw = "row2";
		} else {
			$sw = "row1";
		}
		$zimmer = $zimmer . "<tr class='$sw'>
				<td>" . $daten["Titel"] . "</td>
				<td>" . $daten["SammelZimmer"] . "</td>
				<td>" . $daten["PreisErwachsene"] . "</td>" .
				"<td><a class='BootenLink' href='index.php?tag=$tagID&page=Buchung&MoudeTagID=$MoudeTagID&ZimmerID={$daten['ID']}&AbteilungID={$_GET['AbteilungID']}'>"
				.LangTextOut("Buchung")."</a></td>
				</tr>";

	}
	if ($zimmer)
		$zimmer = $zimmer .
		"</table>";
}
//---------------------------
if ($Gallery) {
	$sql = "select * FROM galerieview where GalerieID=$Gallery";
	$_rd = mysql_query($sql, $_db_link);
	if ($_rd) {
		$Gallery = '<div id="gallery">';
		while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
			$Gallery = $Gallery . '<img src="Admin/UploadFiles/' . $daten["Adresse"] . '">';
		}
		$Gallery = $Gallery . "</div>";
	}
}
?>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
var map;
var marker;
function initialize() {
	
	var myLatlng = new google.maps.LatLng<?PHP echo $datamap; ?>;//(36.81258338428396, 10.156345492431683);
	var myOptions = {
		zoom: 7,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		disableDefaultUI: true,
		navigationControl:true			
	}
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	marker = new google.maps.Marker({
		position: myLatlng, 
		map: map
		});
	var homeControlDiv = document.createElement('DIV');
	var homeControl = new HomeControl(homeControlDiv, map);
	
	homeControlDiv.index = 1;
	map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
}
function showmap(){
	var msgbox=document.getElementById("map_canvas");
	msgbox.style.display = 'block';
	document.getElementById("map_canvas1").style.display = 'block';
	initialize();
	favArea("map_canvas1");
}
function favArea(nameDiv) 
{
	var Element = document.getElementById(nameDiv);
	objh = parseFloat(Element.style.height)/2;
	objw = parseFloat(Element.style.width)/2;
	Element.style.top = Math.floor(Math.round((document.documentElement.offsetHeight/2)+document.documentElement.scrollTop)-objh)+'px';
	Element.style.left = Math.floor(Math.round((document.documentElement.offsetWidth/2)+document.documentElement.scrollLeft)-objw)+'px';
}
function HomeControl(controlDiv, map) {
	controlDiv.style.padding = '5px';
	var controlUI = document.createElement('DIV');
	controlUI.style.cursor = 'pointer';
	controlUI.title = 'Close';
	controlDiv.appendChild(controlUI);
	
	var controlText = document.createElement('DIV');
	controlText.innerHTML = 'Close';
	controlText.setAttribute('class', 'BootenLink');
	
	controlUI.appendChild(controlText);
	
	google.maps.event.addDomListener(controlUI, 'click', function() {
		document.getElementById("map_canvas").style.display = 'none';
		document.getElementById("map_canvas1").style.display = 'none';
		});
}
</script>
<!--Gallery-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script src="galleria/galleria-1.2.5.min.js"></script>
<script>
var swGallery=1;
function  loadGallery(){
 if(swGallery==1){
	Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
	$("#gallery").galleria({
		width: 500,
		height: 400
		});
	favArea("Gallery_canvas");
	swGallery=0;
  }
	document.getElementById("Gallery_canvas").style.display = 'block';	
}
function HideGallery(){
	document.getElementById("Gallery_canvas").style.display = 'none';
}	
</script>

<table class="FirmaView">
<tr>
	<td style="width:60%;vertical-align:top;padding-right:5px">
	<a href="javascript:history.back()" class='BootenLink'><?php LangText('back') ?></a><br><br>
	<?php  echo  $abteilung; echo $zimmer; ?></td>
	<td style="width:40%;vertical-align:top">
	
		<?php

echo $logo;

if ($Gallery != NULL) {
	echo "<br><a href='javascript:loadGallery();' class='BootenLink'>" . LangTextOut("MehrFotos") . "</a>";
}
echo $kontakt;
?>  

	</td>
</tr>
</table>
<!--MAP-->
<div id="map_canvas1" style="width: 500px; height: 400px;">
<div id="map_canvas" style="width: 500px; height: 400px;" ></div>
</div>
<!--Gallery-->
<div id="Gallery_canvas" style="width: 500px; height: 400px;text-align:right">
<a href="javascript:HideGallery()" class="BootenLink" title="Close">Close</a>
<?PHP echo $Gallery; ?>
</div>
	